package com.uniledger.commonlib.easymoney;

import android.content.Context;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;

import com.uniledger.commonlib.R;

public class IconMoneyEditText extends RelativeLayout {

    AppCompatImageView symbol;
    EasyMoneyEditText moneyEditText;

    public IconMoneyEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    void initView(Context context) {
        View view = View.inflate(context, R.layout.edit_icon_money, this);
        symbol = (AppCompatImageView) view.findViewById(R.id.currency_icon);
        moneyEditText = (EasyMoneyEditText) view.findViewById(R.id.edit_transfer_amount);
    }

    public void setSymbol(int res) {
        symbol.setImageResource(res);
    }

    public void setLayoutMarginBottom() {
        LayoutParams params = (RelativeLayout.LayoutParams) symbol.getLayoutParams();
        params.bottomMargin = 0;
    }

    public void setNumberListener(EasyMoneyEditText.NumberListener numberListener) {
        this.moneyEditText.setNumberListener(numberListener);
    }

    public void setAmount(String amount) {
        moneyEditText.setText(amount);
    }

    public EasyMoneyEditText getMoneyEditText() {
        return moneyEditText;
    }
}
